//
//  HLTabBarController.swift
//  HLSwiftWork
//
//  Created by hulinhu on 2018/6/8.
//  Copyright © 2018年 hulinhu. All rights reserved.
//

import UIKit

class HLTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let tabBar = UITabBarItem.appearance()
        let attrs_Nomal = [NSAttributedStringKey.font :UIFont.systemFont(ofSize: 12),NSAttributedStringKey.foregroundColor:UIColor.gray]
        let attrs_Select = [NSAttributedStringKey.font:UIFont.systemFont(ofSize: 12),NSAttributedStringKey.foregroundColor: UIColor.darkGray]
        tabBar.setTitleTextAttributes(attrs_Nomal, for: .normal)
        tabBar.setTitleTextAttributes(attrs_Select, for: .selected)
        
        // 设置UI
        setupUI()
    }
}

extension HLTabBarController {
    
    fileprivate func setupUI() {
        
        
         setValue(CenterPublishTabBar(), forKey: "tabBar")
        
        let VCArray : [UIViewController] = [EssenceViewController(),NewsViewController(),AttentionViewController(),MineViewController()]
        let titleArray = [("精华", "essence"), ("新帖", "new"), ("关注", "friendTrends"), ("我", "me")]
        
        for (index ,vc) in VCArray.enumerated() {
            
            vc.tabBarItem.title = titleArray[index].0
            vc.tabBarItem.image = UIImage(named: "tabBar_\(titleArray[index].1)_icon")
            vc.tabBarItem.selectedImage = UIImage(named: "tabBar_\(titleArray[index].1)_click_icon")
            let nav = HLNavgationController(rootViewController: vc)
            addChildViewController(nav)
        }
        
    }
    
}
